/*include:ace*/
var Judge=Judge||{};
fastCSharp.Copy(Judge,{
PollJudgeId:0,
Load:function()
	{
	var SkinValue=fastCSharp.PageView.SkinValue.SkinValue,Judges=(SkinValue.leftItems||[]).concat(SkinValue.rightItems||[]).Sort(function(Value){return Value.Judge.TestId;});
	this.ReShow(Judges);
	delete fastCSharp.Poll.Query.JudgeId;
	delete fastCSharp.Poll.Query.JudgeTest;
	if(SkinValue.currentUser)
		{
		if(!SkinValue.judge.IsFinished)
			{
			fastCSharp.Poll.Query.JudgeTest=Judges.length?Judges[Judges.length-1].Judge.TestId:0;
			fastCSharp.Poll.Query.JudgeId=SkinValue.judge.Id+this.PollJudgeId;
			if(!this.IsPoll)
				{
				fastCSharp.Poll.OnMessage.Add(fastCSharp.ThisFunction(this,this.OnPoll));
				this.IsPoll=1;
				}
			}
		if(SkinValue.programContent)
			{
			var Judge=fastCSharp.PageView.SkinValue[this.PollJudgeId?'contestJudge':'judge'];
			Comment.Show(this.PollJudgeId?'contestJudge':'judge',Judge.SkinValue.Id,0,Judge.ViewIdentity);
			}
		}
	if(SkinValue.programContent)	fastCSharp.OnModule(['ace.ace'],fastCSharp.ThisFunction(this,this.OnLoadAce),1,1);
	},
ReShow:function(Judges)
	{
	var SkinValue=fastCSharp.PageView.SkinValue,Index=(Judges.length+1)>>1;
	SkinValue.leftItems.Set(Judges.slice(0,Index));
	SkinValue.rightItems.Set(Judges.slice(Index));
	},
OnLoadAce:function()
	{
	var SkinValue=fastCSharp.PageView.SkinValue.SkinValue,Code=SkinValue.programContent;
	if(Code){
		(this.Ace=new fastCSharp.Ace({Id:'programContent',Code:Code,IsReadOnly:1})).Show();
		this.Ace.Editor.setTheme('ace/theme/eclipse');
		this.Ace.Editor.getSession().setMode('ace/mode/'+diantou.judge.GetLanguage(SkinValue.judge.Language).AceMode);
		}
	},
OnPoll:function(Value)
	{
	var SkinValue=fastCSharp.PageView.SkinValue;
	if(Value.Judge)	SkinValue.judge.Copy(Value.Judge);
	if((Value=Value.JudgeItem))
		{
		if(Value.length)
			{
			var Judges=(SkinValue.SkinValue.leftItems||[]).concat(SkinValue.SkinValue.rightItems||[]).concat(Value).Sort(function(Value){return Value.Judge.TestId;});
			this.ReShow(Judges);
			fastCSharp.Poll.Query.JudgeTest=Judges[Judges.length-1].Judge.TestId;
			}
		}
	if(SkinValue.SkinValue.judge.IsFinished)
		{
		delete fastCSharp.Poll.Query.JudgeId;
		delete fastCSharp.Poll.Query.JudgeTest;
		this.OnLoadAce();
		}
	}
		});